Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade path for shipping rate tax data #1068

Merged
merged 1 commit into from Apr 19, 2016
Merged

Upgrade path for shipping rate tax data #1068

merged 1 commit into from Apr 19, 2016

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Apr 14, 2016

Previously, we had a migration that deleted the tax_rate_id column
from the spree_shipping_rates table. Within that migration, we could not
satisfactorily create shipping rate taxes because that required a call to
Spree::TaxRate#compute_amount, for which we can not guarantee the interface
for all future Solidus versions to come.

This compromise works as follows: We keep the column and provide a rake task to
migrate that data up. In a future release (maybe 2.0), we can then add a migration
to delete the column that errors out if there's still data on it (indicating the
migration hasn't been run).

@tvdeyen
Copy link
Member

tvdeyen commented Apr 14, 2016

Perfect! Thank you very much @mamhoff

@cbrunsdon
Copy link
Contributor

I'm very much happy with this compromise 👍

@jhawthorn
Copy link
Contributor

👍

task up: :environment do
puts "Adding persisted tax notes to historic shipping rates"
Spree::ShippingRate.where.not(tax_rate_id: nil).find_each do |shipping_rate|
tax_rate = Spree::TaxRate.unscoped.find_by(id: shipping_rate.tax_rate_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason just to not use find?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No particular reason. Should I amend?

Previously, we had a migration that deleted the `tax_rate_id` column
from the `spree_shipping_rates` table. Within that migration, we could not
satisfactorily create shipping rate taxes because that required a call to
`Spree::TaxRate#compute_amount`, for which we can not guarantee the interface
for all future Solidus versions to come.

This compromise works as follows: We keep the column and provide a rake task to
migrate that data up. In a future release (maybe 2.0), we can then add a migration
to delete the column that errors out if there's still data on it (indicating the
migration hasn't been run).
@mamhoff
Copy link
Contributor Author

mamhoff commented Apr 18, 2016

Amended to use find instead of find_by.

@gmacdougall
Copy link
Member

👍

@jhawthorn jhawthorn merged commit 614759f into solidusio:master Apr 19, 2016
@mamhoff mamhoff deleted the convert-old-broken-migration-to-rake-task branch May 24, 2016 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants